using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using Cxsoft.Web.UI.WebControls;

namespace Cxsoft.Web.UI.Design
{
  public class CoolBarDesign : ControlDesigner
  {

    public override bool AllowResize
    {
      get
      {
        return true;
      }
    }

	  public override string GetDesignTimeHtml()
	  {
		  string text1 = null;
		  string text2 = string.Empty;
		  string text3 = string.Empty;
		  string text4 = string.Empty;
		  CxCoolBar bar1 = (CxCoolBar) base.Component;
		  try
		  {
			  if (bar1.Face == BarStyle.Purple)
			  {
				  bar1.BackColor = Color.FromName("#E3E4E6");
				  bar1.BorderColor = Color.FromName("#7E7C8D");
				  bar1.ForeColor = Color.FromName("#666666");
				  bar1.BorderWidth = 1;
				  bar1.TitleFontColor = Color.FromName("#666666");
				  bar1.TitleBgColor = Color.FromName("#BEC0CF");
			  }
			  if (bar1.Face == BarStyle.Outlook)
			  {
				  bar1.BackColor = Color.Gray;
				  bar1.BorderColor = Color.Black;
				  bar1.ForeColor = Color.Black;
				  bar1.BorderWidth = 1;
				  bar1.TitleFontColor = Color.Black;
				  bar1.TitleBgColor = Color.FromName("#d4d0c8");
			  }
			  if (bar1.Face == BarStyle.Black)
			  {
				  bar1.BackColor = Color.FromName("#CCCCCC");
				  bar1.BorderColor = Color.FromName("#7E7C8D");
				  bar1.ForeColor = Color.Black;
				  bar1.BorderWidth = 1;
				  bar1.TitleFontColor = Color.Black;
				  bar1.TitleBgColor = Color.FromName("#919392");
			  }
			  if (bar1.Face == BarStyle.Blue)
			  {
				  bar1.BackColor = Color.FromName("#D3E9F3");
				  bar1.BorderColor = Color.FromName("#0080C0");
				  bar1.ForeColor = Color.FromName("#666666");
				  bar1.BorderWidth = 1;
				  bar1.TitleFontColor = Color.FromName("#666666");
				  bar1.TitleBgColor = Color.FromName("#ACD9FF");
			  }
			  if (bar1.Face == BarStyle.Green)
			  {
				  bar1.BackColor = Color.FromName("#F8FAF5");
				  bar1.BorderColor = Color.FromName("#88CB45");
				  bar1.ForeColor = Color.FromName("#666666");
				  bar1.BorderWidth = 1;
				  bar1.TitleFontColor = Color.FromName("#666666");
				  bar1.TitleBgColor = Color.FromName("#DFF2AA");
			  }
			  if (bar1.BackColor.IsNamedColor)
			  {
				  text2 = bar1.BackColor.Name;
			  }
			  else
			  {
				  text2 = "#" + bar1.BackColor.Name.Substring(2, 6);
			  }
			  if (bar1.TitleBgColor.IsNamedColor)
			  {
				  text4 = bar1.TitleBgColor.Name;
			  }
			  else
			  {
				  text4 = "#" + bar1.TitleBgColor.Name.Substring(2, 6);
			  }
			  if (bar1.TitleFontColor.IsNamedColor)
			  {
				  text3 = bar1.TitleFontColor.Name;
			  }
			  else
			  {
				  text3 = "#" + bar1.TitleFontColor.Name.Substring(2, 6);
			  }
			  string text5 = "<div style='border-width: 1px; border-style: dotted; border-color: black; width:{0}; height: {1}'>\r\n\t\t\t\t\t<table border=0 cellpadding=3 cellspacing=0 width=100% height=100%>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size: 11px;' height={2} bgcolor='{3}'><font color='{4}'>CxSoft</font></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size: 11px;' bgcolor='{5}'><img border=0></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size:11px;' bgcolor='{5}'><font color='{4}'>\u7f51\u7ad9</font></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size:11px;' bgcolor='{5}'><img border=0></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size:11px;' bgcolor='{5}'><font color='{4}'>\u5e2e\u52a9</font></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size:11px;' bgcolor='{5}'><img border=0></td></tr>\r\n\t\t\t\t\t<tr><td valign=middle align=center style='font-size:11px;' bgcolor='{5}'><font color='{4}'>\u8d2d\u4e70</font></td></tr>\r\n\t\t\t\t\t</table></div>";
			  object[] objArray1 = new object[6] { bar1.Width, bar1.Height, bar1.TitleHight, text4, text3, text2 } ;
			  text5 = string.Format(text5, objArray1);
			  text1 = text5;
		  }
		  catch (Exception exception1)
		  {
			  text1 = this.GetErrorDesignTimeHtml(exception1);
		  }
		  if ((text1 != null) && (text1.Length != 0))
		  {
			  return text1;
		  }
		  return this.GetEmptyDesignTimeHtml();
	  }


    protected override string GetErrorDesignTimeHtml(Exception e)
    {
      return string.Concat(new string[]{"<font color=red><b>\u63a7\u4ef6\u6784\u9020\u51fa\u9519\uff0c\u4fe1\u606f\u4e3a\uff1a", e.Message, "\n\u6e90\u81ea\uff1a", e.Source, "\n\u66f4\u591a\u5e2e\u52a9\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95ee\u7f51\u7ad9\uff1ahttp://www.aspxcontrol.com</b></font>"});
    }

    protected override string GetEmptyDesignTimeHtml()
    {
      return base.CreatePlaceHolderDesignTimeHtml("CxCoolBar");
    }
  }

}
